"""通用响应模型"""
from typing import Generic, Optional, TypeVar, Any
from pydantic import BaseModel

T = TypeVar('T')


class ResponseModel(BaseModel, Generic[T]):
    """通用响应模型"""
    code: int = 200
    message: str = "success"
    data: Optional[T] = None
    

class PageRequest(BaseModel):
    """分页请求参数"""
    page: int = 1
    pageSize: int = 10
    
    class Config:
        json_schema_extra = {
            "example": {
                "page": 1,
                "pageSize": 10
            }
        }


class PageResponse(BaseModel, Generic[T]):
    """分页响应模型"""
    list: list[T]
    total: int
    page: int
    pageSize: int
    totalPages: int
